package com.yanqu.road.server.cmd.minewar;

import com.yanqu.road.server.pb.MineWarPb;
import com.yanqu.road.entity.minewar.MineWarRecord;
import com.yanqu.road.pb.minewar.MineWarProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.player.MineWarMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.server.command.Cmd;

import java.util.List;

@Cmd(code = Protocol.S_MINE_WAR_RECORD, desc = "矿战战斗记录")
public class MineWarRecordCmd extends AbstractCommand {

	private List<MineWarRecord> recordList;

	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		recordList = MineWarMgr.getUserMineWarRecord(player.getUserId());
	}

	@Override
	public void sendData(GamePlayer player) {
		MineWarProto.MineWarRecordListMsg.Builder respMsg = MineWarPb.parseMineWarRecordListMsg(recordList);
		player.sendPacket(Protocol.U_MINE_WAR_RECORD, respMsg);
	}
}
